package cn.itcast.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 *
 * @Author mr.wei
 * @Date 2025/1/5 上午11:06
 */
@Configuration
public class RabbitConfig {

    @Bean
    public Queue simpleQueue() {
        return new Queue("simple.queue", true);
    }

    @Bean
    public Queue workQueue() {
        return new Queue("work.queue", true);
    }

    @Bean
    public Queue fanoutQueue1() {
        return new Queue("fanout.queue1", true);
    }
    @Bean
    public Queue fanoutQueue2() {
        return new Queue("fanout.queue2", true);
    }
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("itcast.fanout");
    }
    @Bean
    public Binding bindingFanout1(Queue fanoutQueue1, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);
    }
    @Bean
    public Binding bindingFanout2(Queue fanoutQueue2, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue2).to(fanoutExchange);
    }
    @Bean
    public Queue objectQueue(){
        return new Queue ("object.queue");
    }
}
